'use strict';

const _  = require('lodash');

console.log('chunk，按长度要求截断成若干部分', _.chunk(_.range(10), 3));
console.log('compact 去掉0和null等值', _.compact([1,2,0,null,3]));
console.log('difference 差集', _.difference([1,2,3], [2,4]));
console.log('intersection 交集', _.intersection([1,2,3], [2,4]));
console.log('drop 删除n个元素', _.drop([1,2,3,4], 2));
console.log('initial 删除最后一个元素', _.initial([1,2,3,4]));
console.log('pull 删除指定值的元素', _.pull([1,2,3,4], 2, 3));

console.log('keyBy 好用，快速把array变成一个缓存的对象', _.keyBy([{id:1}, {id:2},{id:3}], 'id'));